<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="快递单号:" class="myform-item">
          <el-input
            v-model="form.courier_number"
            placeholder="请输入快递单号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="出库时间:" class="myform-item">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="form.createtime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
          <!-- <el-button type="primary" @click="onAdd">新增面料</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%"
      border
    >
      <el-table-column
        label="快递单号"
        align="center"
        prop="courier_number"
      >
      </el-table-column>
      <el-table-column label="RFID" align="center" prop="numberarr">
        <template slot-scope="{ row }">
          <div v-for="(item, index) in row.numberarr" :key="index">
            {{ item.number }}
          </div>
        </template>
      </el-table-column>

      <el-table-column label="出库时间" align="center" prop="createtime">
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminCodeGetWarehouseList"
    />
  </div>
</template>

<script>
import { postAdminCodeGetWarehouseList } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      tableData: [],
      total: 1,
      form: {
        page: 1,
        size: 10,
        courier_number: "",
        createtime: "",
      },
    };
  },
  activated() {
    let form = this.form;
    this.postAdminCodeGetWarehouseList(form);
  },
  methods: {
    // 采购列表
    async postAdminCodeGetWarehouseList(data) {
      this.loading = true;
      let form = JSON.parse(JSON.stringify(data));
      if (form.createtime) {
        form.createtime = `${form.createtime[0]}/${form.createtime[1]}`;
      }
      postAdminCodeGetWarehouseList(form)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminCodeGetWarehouseList(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
